//
//  UIView+AF.m
//  AFChat
//
//  Created by Void on 2018/6/22.
//  Copyright © 2018年 afei. All rights reserved.
//

#import "UIView+AF.h"

@implementation UIView (AF)

#pragma mark - Setter
- (void)setAf_centerX:(CGFloat)af_centerX {
    CGPoint center = self.center;
    center.x = af_centerX;
    self.center = center;
}
- (void)setAf_centerY:(CGFloat)af_centerY {
    CGPoint center = self.center;
    center.y = af_centerY;
    self.center = center;
}

- (void)setAf_x:(CGFloat)af_x {
    CGRect frame = self.frame;
    frame.origin.x = af_x;
    self.frame = frame;
}
- (void)setAf_y:(CGFloat)af_y {
    CGRect frame = self.frame;
    frame.origin.y = af_y;
    self.frame = frame;
}

- (void)setAf_width:(CGFloat)af_width {
    CGRect frame = self.frame;
    frame.size.width = af_width;
    self.frame = frame;
}
- (void)setAf_height:(CGFloat)af_height {
    CGRect frame = self.frame;
    frame.size.height = af_height;
    self.frame = frame;
}

- (void)setAf_origin:(CGPoint)af_origin {
    CGRect frame = self.frame;
    frame.origin = af_origin;
    self.frame = frame;
}
- (void)setAf_size:(CGSize)af_size {
    CGRect frame = self.frame;
    frame.size = af_size;
    self.frame = frame;
}

- (void)setFrameRight:(CGFloat)frameRight {
    self.frame = CGRectMake(frameRight - self.frame.size.width, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
}
- (void)setFrameBottom:(CGFloat)frameBottom {
    self.frame = CGRectMake(self.frame.origin.x, frameBottom - self.frame.origin.y, self.frame.size.width, self.frame.size.height);
}

#pragma mark - Getter
- (CGFloat)af_centerX {
    return self.center.x;
}
- (CGFloat)af_centerY {
    return self.center.y;
}

- (CGFloat)af_x {
    return self.frame.origin.x;
}
- (CGFloat)af_y {
    return self.frame.origin.y;
}

- (CGFloat)af_width {
    return self.frame.size.width;
}
- (CGFloat)af_height {
    return self.frame.size.height;
}

- (CGPoint)af_origin {
    return self.frame.origin;
}
- (CGSize)af_size {
    return self.frame.size;
}

- (CGFloat)frameRight {
    return self.frame.origin.x + self.frame.size.width;
}
- (CGFloat)frameBottom {
    return self.frame.origin.y + self.frame.size.height;
}

@end
